home *** CD-ROM | disk | FTP | other *** search
- // demo mode dll
- #include <windows.h>
- #pragma hdrstop
-
- #include <stdlib.h>
- #include <values.h>
-
- #include "demo.h"
-
- #pragma argsused
- int CALLBACK LibMain(HINSTANCE hinst,WORD wDataSeg,WORD cbHeapSize,LPSTR lpszCmdLine)
- {
- return 1;
- }
-
- int _export CALLBACK WEP(int)
- {
- return 1;
- }
-
- DemoInfo Info={"Defendroid",VERSION,"Test Demo","Test Demo"};
- DemoProc FirstObject,NextObject;
-
- DemoInfo * _export CALLBACK Initialize(DemoProc F,DemoProc N)
- {
- FirstObject=F;
- NextObject=N;
- return &Info;
- }
-
- // this function is called at the start of a game
- void _export CALLBACK GameInit()
- {
- }
-
- // this function is called at the end of a game
- // to inform the DLL of the attained score and wasted smart bombs
- void _export CALLBACK GameOver(DWORD /*Score*/,WORD /*Smarts*/)
- {
- }
-
-
- #define FIRERANGE 280
-
- void _export CALLBACK ControlDemo(GameInfo *G)
- {
- GameObject O,CloseObj;
- CloseObj.Valid=0;
-
- FirstObject(&O);
- int d=MAXINT;
- while (O.Valid)
- {
- if (O.Type!=HUMANOID && !(O.Flags & O_SMALLWEAP))
- {
- int dx=abs(SIGNX(O.x-G->Ship.x));
- if (dx<d)
- {
- CloseObj=O;
- d=dx;
- }
- }
- NextObject(&O);
- }
-
- Controls::BITS &B=G->C->bits;
- if (CloseObj.Valid)
- {
- B.Dir=SIGNX(CloseObj.x-G->Ship.x)<0;
- B.Thrust=TRUE;
- if (INRANGE(SIGNX(CloseObj.x-G->Ship.x),FIRERANGE)) B.Fire=G->Frame%6==0;
- B.Up=CloseObj.y-G->Ship.y<1;
- B.Down=CloseObj.y-G->Ship.y>1;
- }
- }
-
-